
* Open data
use "WLS21_main.dta", replace

* To install user-written packages, remove the *
*ssc install distinct, replace
*ssc install reghdfe, replace





**************************************
** TABLE 1: Demographic Composition **
**************************************

egen pickone = tag(voter_id)
tab voter_female if pickone == 1
foreach var of varlist age_1519 age_2029 age_3039 age_4049 age_5059 age_6069 age_70plus {
	tab `var' if pickone == 1
}
tab degree if pickone == 1




*************************************
** TABLE 2: Descriptive Statistics **
*************************************

* Restrict to cases in which candidates participated in the elite survey (and we therefore have data on candidates' policy positions)
sum cand_vint prox_cand prox_cand_sal voter_interest prox_party party_id party_GE2019 cand_lwin  if cand_survey == 1




***************************
** TABLE 3: Main Results **
***************************

* Model 1
reg cand_vint prox_cand, cl(voter_id)
estimates store m1
	* Number of candidates
	distinct cand_id if e(sample)
	estadd local N_cand `r(ndistinct)'


* Model 2
xtreg cand_vint prox_cand prox_party party_id party_GE2019 cand_lwin i.cand_id, cl(voter_id) fe i(voter_id)
estimates store m2
	* Number of candidates
	distinct cand_id if e(sample)
	estadd local N_cand `r(ndistinct)'

	
* Model 3
gen xz = prox_cand * voter_interest
xtreg cand_vint prox_cand xz prox_party party_id party_GE2019 cand_lwin i.cand_id, cl(voter_id) fe i(voter_id)
estimates store m3
	* Number of candidates
	distinct cand_id if e(sample)
	estadd local N_cand `r(ndistinct)'
drop xz	
	
	
* Model 4
reg cand_vint prox_cand_sal, cl(voter_id)
estimates store m4
	* Number of candidates
	distinct cand_id if e(sample)
	estadd local N_cand `r(ndistinct)'	

	
* Model 5
xtreg cand_vint prox_cand_sal prox_party party_id party_GE2019 cand_lwin i.cand_id, cl(voter_id) fe i(voter_id)
estimates store m5
	* Number of candidates
	distinct cand_id if e(sample)
	estadd local N_cand `r(ndistinct)'


* Model 6
gen xz = prox_cand_sal * voter_interest
xtreg cand_vint prox_cand_sal xz prox_party party_id party_GE2019 cand_lwin i.cand_id, cl(voter_id) fe i(voter_id)
estimates store m6
	* Number of candidates
	distinct cand_id if e(sample)
	estadd local N_cand `r(ndistinct)'
drop xz	


	


**************************************
** FIGURE 1: Conditional Effects Plots
**************************************


* All issues
xtreg cand_vint prox_cand c.prox_cand#c.voter_interest prox_party party_id party_GE2019 cand_lwin i.cand_id, cl(voter_id) fe i(voter_id)
gen sample = e(sample)
margins, dydx(prox_cand) at(voter_interest = (1(1)4)) post
generate MVZ= _n
replace  MVZ= . if MVZ > 4
gen conbx = _b[prox_cand:1bn._at] if MVZ == 1
replace conbx = _b[prox_cand:2._at] if MVZ == 2
replace conbx = _b[prox_cand:3._at] if MVZ == 3
replace conbx = _b[prox_cand:4._at] if MVZ == 4
gen consx = _se[prox_cand:1bn._at] if MVZ == 1
replace consx = _se[prox_cand:2._at] if MVZ == 2
replace consx = _se[prox_cand:3._at] if MVZ == 3
replace consx = _se[prox_cand:4._at] if MVZ == 4
gen ax = 1.96 * consx
gen upperx = conbx + ax
gen lowerx = conbx - ax
sum prox_cand
scalar sd = `r(sd)'
foreach var of varlist conbx consx ax upperx lowerx {
replace `var' = `var' * sd	
}
twoway 	(hist voter_interest if sample == 1, width(0.25) percent color(gs14) discrete fintensity(100) yaxis(2) ) ///
		(scatter conbx MVZ, mcolor(black) msize(medsmall) msymbol(circle) yaxis(1)) ///
		(rspike lowerx upperx MVZ, lcolor(black) lwidth(medthin) lpattern(solid) yaxis(1)) ///
		, ///
		ytitle("Effect of a standard deviation increase in a" "voter's proximity to a candidate on candidate vote intention", size(small)) ///
		ytitle("", axis(2)) ///
		ylabel(-0.06(0.02)0.06, labsize(small) noticks gmin gmax) ///
		ylabel(, noticks nolabels axis(2)) ///
		yscale(noline alt) yscale(noline alt range(0 200) axis(2))	 ///
		yline(0, lwidth(medthin) lpattern(solid)) ///
		xtitle("Interest in election", size(small)) ///
		xscale(range(0.9 4.1) noline) ///
		xlabel(1 "Very low" 2 "Low" 3 "High" 4 "Very high", labels labsize(small) angle(horizontal) noticks) ///
		title("All issues", margin(bottom)) ///
		legend(off) xsize(3) ysize(4) saving(all, replace)
drop sample - lowerx

* Personally salient issues
xtreg cand_vint prox_cand_sal c.prox_cand_sal#c.voter_interest prox_party party_id party_GE2019 cand_lwin i.cand_id, cl(voter_id) fe i(voter_id)
gen sample = e(sample)
margins, dydx(prox_cand_sal) at(voter_interest = (1(1)4)) post
generate MVZ= _n
replace  MVZ= . if MVZ > 4
gen conbx = _b[prox_cand_sal:1bn._at] if MVZ == 1
replace conbx = _b[prox_cand_sal:2._at] if MVZ == 2
replace conbx = _b[prox_cand_sal:3._at] if MVZ == 3
replace conbx = _b[prox_cand_sal:4._at] if MVZ == 4
gen consx = _se[prox_cand_sal:1bn._at] if MVZ == 1
replace consx = _se[prox_cand_sal:2._at] if MVZ == 2
replace consx = _se[prox_cand_sal:3._at] if MVZ == 3
replace consx = _se[prox_cand_sal:4._at] if MVZ == 4
gen ax = 1.96 * consx
gen upperx = conbx + ax
gen lowerx = conbx - ax
sum prox_cand_sal
scalar sd = `r(sd)'
foreach var of varlist conbx consx ax upperx lowerx {
replace `var' = `var' * sd	
}
twoway (hist voter_interest if sample == 1, width(0.25) percent color(gs14) discrete fintensity(100) yaxis(2) ) ///
		(scatter conbx MVZ, mcolor(black) msize(medsmall) msymbol(circle) yaxis(1)) ///
		(rspike lowerx upperx MVZ, lcolor(black) lwidth(medthin) lpattern(solid) yaxis(1)) ///
		, ///
		ytitle("Effect of a standard deviation increase in a" "voter's proximity to a candidate on candidate vote intention", size(small)) ///
		ytitle("", axis(2)) ///
		ylabel(-0.06(0.02)0.06, labsize(small) noticks gmin gmax) ///
		ylabel(, noticks nolabels axis(2)) ///
		yscale(noline alt) yscale(noline alt range(0 200) axis(2))	 ///
		yline(0, lwidth(medthin) lpattern(solid)) ///
		xtitle("Interest in election", size(small)) ///
		xscale(range(0.9 4.1) noline) ///
		xlabel(1 "Very low" 2 "Low" 3 "High" 4 "Very high", labels labsize(small) angle(horizontal) noticks) ///
		title("Personally salient issues", margin(bottom)) ///
		legend(off) xsize(3) ysize(4) saving(salient, replace)
drop sample - lowerx


* Combine graphs
graph combine all.gph salient.gph, scale(1.1)






**********************************
** ROBUSTNESS 1: Survey weights **
**********************************

* Model 1
reg cand_vint prox_cand [pweight = weight], cl(voter_id)
estimates store m1
	* Number of candidates
	distinct cand_id if e(sample)
	estadd local N_cand `r(ndistinct)'


* Model 2
xtreg cand_vint prox_cand prox_party party_id party_GE2019 cand_lwin i.cand_id [pweight = weight], cl(voter_id) fe i(voter_id)
estimates store m2
	* Number of candidates
	distinct cand_id if e(sample)
	estadd local N_cand `r(ndistinct)'

	
* Model 3
gen xz = prox_cand * voter_interest
xtreg cand_vint prox_cand xz prox_party party_id party_GE2019 cand_lwin i.cand_id [pweight = weight], cl(voter_id) fe i(voter_id)
estimates store m3
	* Number of candidates
	distinct cand_id if e(sample)
	estadd local N_cand `r(ndistinct)'
drop xz	
	
	
* Model 4
reg cand_vint prox_cand_sal [pweight = weight], cl(voter_id)
estimates store m4
	* Number of candidates
	distinct cand_id if e(sample)
	estadd local N_cand `r(ndistinct)'	

	
* Model 5
xtreg cand_vint prox_cand_sal prox_party party_id party_GE2019 cand_lwin i.cand_id [pweight = weight], cl(voter_id) fe i(voter_id)
estimates store m5
	* Number of candidates
	distinct cand_id if e(sample)
	estadd local N_cand `r(ndistinct)'


* Model 6
gen xz = prox_cand_sal * voter_interest
xtreg cand_vint prox_cand_sal xz prox_party party_id party_GE2019 cand_lwin i.cand_id [pweight = weight], cl(voter_id) fe i(voter_id)
estimates store m6
	* Number of candidates
	distinct cand_id if e(sample)
	estadd local N_cand `r(ndistinct)'
drop xz	


	
	
* Figure

* All issues
xtreg cand_vint prox_cand c.prox_cand#c.voter_interest prox_party party_id party_GE2019 cand_lwin i.cand_id [pweight = weight], cl(voter_id) fe i(voter_id)
gen sample = e(sample)
margins, dydx(prox_cand) at(voter_interest = (1(1)4)) post
generate MVZ= _n
replace  MVZ= . if MVZ > 4
gen conbx = _b[prox_cand:1bn._at] if MVZ == 1
replace conbx = _b[prox_cand:2._at] if MVZ == 2
replace conbx = _b[prox_cand:3._at] if MVZ == 3
replace conbx = _b[prox_cand:4._at] if MVZ == 4
gen consx = _se[prox_cand:1bn._at] if MVZ == 1
replace consx = _se[prox_cand:2._at] if MVZ == 2
replace consx = _se[prox_cand:3._at] if MVZ == 3
replace consx = _se[prox_cand:4._at] if MVZ == 4
gen ax = 1.96 * consx
gen upperx = conbx + ax
gen lowerx = conbx - ax
sum prox_cand
scalar sd = `r(sd)'
foreach var of varlist conbx consx ax upperx lowerx {
replace `var' = `var' * sd	
}
twoway 	(hist voter_interest if sample == 1, width(0.25) percent color(gs14) discrete fintensity(100) yaxis(2) ) ///
		(scatter conbx MVZ, mcolor(black) msize(medsmall) msymbol(circle) yaxis(1)) ///
		(rspike lowerx upperx MVZ, lcolor(black) lwidth(medthin) lpattern(solid) yaxis(1)) ///
		, ///
		ytitle("Effect of a standard deviation increase in a" "voter's proximity to a candidate on candidate vote intention", size(small)) ///
		ytitle("", axis(2)) ///
		ylabel(-0.06(0.02)0.06, labsize(small) noticks gmin gmax) ///
		ylabel(, noticks nolabels axis(2)) ///
		yscale(noline alt) yscale(noline alt range(0 200) axis(2))	 ///
		yline(0, lwidth(medthin) lpattern(solid)) ///
		xtitle("Interest in election", size(small)) ///
		xscale(range(0.9 4.1) noline) ///
		xlabel(1 "Very low" 2 "Low" 3 "High" 4 "Very high", labels labsize(small) angle(horizontal) noticks) ///
		title("All issues", margin(bottom)) ///
		legend(off) xsize(3) ysize(4) saving(all, replace)
drop sample - lowerx

* Personally salient issues
xtreg cand_vint prox_cand_sal c.prox_cand_sal#c.voter_interest prox_party party_id party_GE2019 cand_lwin i.cand_id [pweight = weight], cl(voter_id) fe i(voter_id)
gen sample = e(sample)
margins, dydx(prox_cand_sal) at(voter_interest = (1(1)4)) post
generate MVZ= _n
replace  MVZ= . if MVZ > 4
gen conbx = _b[prox_cand_sal:1bn._at] if MVZ == 1
replace conbx = _b[prox_cand_sal:2._at] if MVZ == 2
replace conbx = _b[prox_cand_sal:3._at] if MVZ == 3
replace conbx = _b[prox_cand_sal:4._at] if MVZ == 4
gen consx = _se[prox_cand_sal:1bn._at] if MVZ == 1
replace consx = _se[prox_cand_sal:2._at] if MVZ == 2
replace consx = _se[prox_cand_sal:3._at] if MVZ == 3
replace consx = _se[prox_cand_sal:4._at] if MVZ == 4
gen ax = 1.96 * consx
gen upperx = conbx + ax
gen lowerx = conbx - ax
sum prox_cand_sal
scalar sd = `r(sd)'
foreach var of varlist conbx consx ax upperx lowerx {
replace `var' = `var' * sd	
}
twoway (hist voter_interest if sample == 1, width(0.25) percent color(gs14) discrete fintensity(100) yaxis(2) ) ///
		(scatter conbx MVZ, mcolor(black) msize(medsmall) msymbol(circle) yaxis(1)) ///
		(rspike lowerx upperx MVZ, lcolor(black) lwidth(medthin) lpattern(solid) yaxis(1)) ///
		, ///
		ytitle("Effect of a standard deviation increase in a" "voter's proximity to a candidate on candidate vote intention", size(small)) ///
		ytitle("", axis(2)) ///
		ylabel(-0.06(0.02)0.06, labsize(small) noticks gmin gmax) ///
		ylabel(, noticks nolabels axis(2)) ///
		yscale(noline alt) yscale(noline alt range(0 200) axis(2))	 ///
		yline(0, lwidth(medthin) lpattern(solid)) ///
		xtitle("Interest in election", size(small)) ///
		xscale(range(0.9 4.1) noline) ///
		xlabel(1 "Very low" 2 "Low" 3 "High" 4 "Very high", labels labsize(small) angle(horizontal) noticks) ///
		title("Personally salient issues", margin(bottom)) ///
		legend(off) xsize(3) ysize(4) saving(salient, replace)
drop sample - lowerx


* Combine graphs
graph combine all.gph salient.gph, scale(1.1)

* Tidy up
erase "all.gph"
erase "salient.gph"







***************************************
** ROBUSTNESS 2: Additional controls **
***************************************


* Model 1
reg cand_vint prox_cand, cl(voter_id)
estimates store m1
	* Number of candidates
	distinct cand_id if e(sample)
	estadd local N_cand `r(ndistinct)'


* Model 2
xtreg cand_vint prox_cand prox_party party_id party_GE2019 cand_lwin i.cand_id prox_party_sal 1.voter_female#i.cand_id c.voter_age#i.cand_id c.voter_edu#i.cand_id, cl(voter_id) fe i(voter_id)
estimates store m2
	* Number of candidates
	distinct cand_id if e(sample)
	estadd local N_cand `r(ndistinct)'

	
* Model 3
gen xz = prox_cand * voter_interest
xtreg cand_vint prox_cand xz prox_party party_id party_GE2019 cand_lwin i.cand_id prox_party_sal 1.voter_female#i.cand_id c.voter_age#i.cand_id c.voter_edu#i.cand_id, cl(voter_id) fe i(voter_id)
estimates store m3
	* Number of candidates
	distinct cand_id if e(sample)
	estadd local N_cand `r(ndistinct)'
drop xz	
	
	
* Model 4
reg cand_vint prox_cand_sal, cl(voter_id)
estimates store m4
	* Number of candidates
	distinct cand_id if e(sample)
	estadd local N_cand `r(ndistinct)'	
	
	
* Model 5
xtreg cand_vint prox_cand_sal prox_party party_id party_GE2019 cand_lwin i.cand_id prox_party_sal 1.voter_female#i.cand_id c.voter_age#i.cand_id c.voter_edu#i.cand_id, cl(voter_id) fe i(voter_id)
estimates store m5
	* Number of candidates
	distinct cand_id if e(sample)
	estadd local N_cand `r(ndistinct)'
	

* Model 6
gen xz = prox_cand_sal * voter_interest
xtreg cand_vint prox_cand_sal xz prox_party party_id party_GE2019 cand_lwin i.cand_id prox_party_sal 1.voter_female#i.cand_id c.voter_age#i.cand_id c.voter_edu#i.cand_id, cl(voter_id) fe i(voter_id)
estimates store m6
	* Number of candidates
	distinct cand_id if e(sample)
	estadd local N_cand `r(ndistinct)'
drop xz	



* Figure


* All issues
xtreg cand_vint prox_cand c.prox_cand#c.voter_interest prox_party party_id party_GE2019 cand_lwin i.cand_id prox_party_sal 1.voter_female#i.cand_id c.voter_age#i.cand_id c.voter_edu#i.cand_id, cl(voter_id) fe i(voter_id)
gen sample = e(sample)
margins, dydx(prox_cand) at(voter_interest = (1(1)4)) post
generate MVZ= _n
replace  MVZ= . if MVZ > 4
gen conbx = _b[prox_cand:1bn._at] if MVZ == 1
replace conbx = _b[prox_cand:2._at] if MVZ == 2
replace conbx = _b[prox_cand:3._at] if MVZ == 3
replace conbx = _b[prox_cand:4._at] if MVZ == 4
gen consx = _se[prox_cand:1bn._at] if MVZ == 1
replace consx = _se[prox_cand:2._at] if MVZ == 2
replace consx = _se[prox_cand:3._at] if MVZ == 3
replace consx = _se[prox_cand:4._at] if MVZ == 4
gen ax = 1.96 * consx
gen upperx = conbx + ax
gen lowerx = conbx - ax
sum prox_cand
scalar sd = `r(sd)'
foreach var of varlist conbx consx ax upperx lowerx {
replace `var' = `var' * sd	
}
twoway 	(hist voter_interest if sample == 1, width(0.25) percent color(gs14) discrete fintensity(100) yaxis(2) ) ///
		(scatter conbx MVZ, mcolor(black) msize(medsmall) msymbol(circle) yaxis(1)) ///
		(rspike lowerx upperx MVZ, lcolor(black) lwidth(medthin) lpattern(solid) yaxis(1)) ///
		, ///
		ytitle("Effect of a standard deviation increase in a" "voter's proximity to a candidate on candidate vote intention", size(small)) ///
		ytitle("", axis(2)) ///
		ylabel(-0.04(0.02)0.06, labsize(small) noticks gmin gmax) ///
		ylabel(, noticks nolabels axis(2)) ///
		yscale(noline alt) yscale(noline alt range(0 200) axis(2))	 ///
		yline(0, lwidth(medthin) lpattern(solid)) ///
		xtitle("Interest in election", size(small)) ///
		xscale(range(0.9 4.1) noline) ///
		xlabel(1 "Very low" 2 "Low" 3 "High" 4 "Very high", labels labsize(small) angle(horizontal) noticks) ///
		title("All issues", margin(bottom)) ///
		legend(off) xsize(3) ysize(4) saving(all, replace)
drop sample - lowerx

* Personally salient issues
xtreg cand_vint prox_cand_sal c.prox_cand_sal#c.voter_interes prox_party party_id party_GE2019 cand_lwin i.cand_id prox_party_sal 1.voter_female#i.cand_id c.voter_age#i.cand_id c.voter_edu#i.cand_id, cl(voter_id) fe i(voter_id)
gen sample = e(sample)
margins, dydx(prox_cand_sal) at(voter_interest = (1(1)4)) post
generate MVZ= _n
replace  MVZ= . if MVZ > 4
gen conbx = _b[prox_cand_sal:1bn._at] if MVZ == 1
replace conbx = _b[prox_cand_sal:2._at] if MVZ == 2
replace conbx = _b[prox_cand_sal:3._at] if MVZ == 3
replace conbx = _b[prox_cand_sal:4._at] if MVZ == 4
gen consx = _se[prox_cand_sal:1bn._at] if MVZ == 1
replace consx = _se[prox_cand_sal:2._at] if MVZ == 2
replace consx = _se[prox_cand_sal:3._at] if MVZ == 3
replace consx = _se[prox_cand_sal:4._at] if MVZ == 4
gen ax = 1.96 * consx
gen upperx = conbx + ax
gen lowerx = conbx - ax
sum prox_cand_sal
scalar sd = `r(sd)'
foreach var of varlist conbx consx ax upperx lowerx {
replace `var' = `var' * sd	
}
twoway (hist voter_interest if sample == 1, width(0.25) percent color(gs14) discrete fintensity(100) yaxis(2) ) ///
		(scatter conbx MVZ, mcolor(black) msize(medsmall) msymbol(circle) yaxis(1)) ///
		(rspike lowerx upperx MVZ, lcolor(black) lwidth(medthin) lpattern(solid) yaxis(1)) ///
		, ///
		ytitle("Effect of a standard deviation increase in a" "voter's proximity to a candidate on candidate vote intention", size(small)) ///
		ytitle("", axis(2)) ///
		ylabel(-0.04(0.02)0.06, labsize(small) noticks gmin gmax) ///
		ylabel(, noticks nolabels axis(2)) ///
		yscale(noline alt) yscale(noline alt range(0 200) axis(2))	 ///
		yline(0, lwidth(medthin) lpattern(solid)) ///
		xtitle("Interest in election", size(small)) ///
		xscale(range(0.9 4.1) noline) ///
		xlabel(1 "Very low" 2 "Low" 3 "High" 4 "Very high", labels labsize(small) angle(horizontal) noticks) ///
		title("Personally salient issues", margin(bottom)) ///
		legend(off) xsize(3) ysize(4) saving(salient, replace)
drop sample - lowerx


* Combine graphs
graph combine all.gph salient.gph, scale(1.1)

* Tidy up
erase "all.gph"
erase "salient.gph"






*****************************************
** ROBUSTNESS 3: Reducing collinearity **
*****************************************

* Model 1
reg cand_vint prox_cand15, cl(voter_id)
estimates store m1
	* Number of candidates
	distinct cand_id if e(sample)
	estadd local N_cand `r(ndistinct)'


* Model 2
xtreg cand_vint prox_cand15 prox_party15 party_id party_GE2019 cand_lwin i.cand_id, cl(voter_id) fe i(voter_id)
estimates store m2
	* Number of candidates
	distinct cand_id if e(sample)
	estadd local N_cand `r(ndistinct)'

	
* Model 3
gen xz = prox_cand15 * voter_interest
xtreg cand_vint prox_cand15 xz prox_party15 party_id party_GE2019 cand_lwin i.cand_id, cl(voter_id) fe i(voter_id)
estimates store m3
	* Number of candidates
	distinct cand_id if e(sample)
	estadd local N_cand `r(ndistinct)'
drop xz	
	
	
* Model 4
reg cand_vint prox_cand_sal15, cl(voter_id)
estimates store m4
	* Number of candidates
	distinct cand_id if e(sample)
	estadd local N_cand `r(ndistinct)'	

	
* Model 5
xtreg cand_vint prox_cand_sal15 prox_party15 party_id party_GE2019 cand_lwin i.cand_id, cl(voter_id) fe i(voter_id)
estimates store m5
	* Number of candidates
	distinct cand_id if e(sample)
	estadd local N_cand `r(ndistinct)'


* Model 6
gen xz = prox_cand_sal15 * voter_interest
xtreg cand_vint prox_cand_sal15 xz prox_party15 party_id party_GE2019 cand_lwin i.cand_id, cl(voter_id) fe i(voter_id)
estimates store m6
	* Number of candidates
	distinct cand_id if e(sample)
	estadd local N_cand `r(ndistinct)'
drop xz	



	

* Figure


* All issues
xtreg cand_vint prox_cand15 c.prox_cand15#c.voter_interest prox_party15 party_id party_GE2019 cand_lwin i.cand_id, cl(voter_id) fe i(voter_id)
gen sample = e(sample)
margins, dydx(prox_cand15) at(voter_interest = (1(1)4)) post
generate MVZ= _n
replace  MVZ= . if MVZ > 4
gen conbx = _b[prox_cand15:1bn._at] if MVZ == 1
replace conbx = _b[prox_cand15:2._at] if MVZ == 2
replace conbx = _b[prox_cand15:3._at] if MVZ == 3
replace conbx = _b[prox_cand15:4._at] if MVZ == 4
gen consx = _se[prox_cand15:1bn._at] if MVZ == 1
replace consx = _se[prox_cand15:2._at] if MVZ == 2
replace consx = _se[prox_cand15:3._at] if MVZ == 3
replace consx = _se[prox_cand15:4._at] if MVZ == 4
gen ax = 1.96 * consx
gen upperx = conbx + ax
gen lowerx = conbx - ax
sum prox_cand15
scalar sd = `r(sd)'
foreach var of varlist conbx consx ax upperx lowerx {
replace `var' = `var' * sd	
}
twoway 	(hist voter_interest if sample == 1, width(0.25) percent color(gs14) discrete fintensity(100) yaxis(2) ) ///
		(scatter conbx MVZ, mcolor(black) msize(medsmall) msymbol(circle) yaxis(1)) ///
		(rspike lowerx upperx MVZ, lcolor(black) lwidth(medthin) lpattern(solid) yaxis(1)) ///
		, ///
		ytitle("Effect of a standard deviation increase in a" "voter's proximity to a candidate on candidate vote intention", size(small)) ///
		ytitle("", axis(2)) ///
		ylabel(-0.06(0.02)0.06, labsize(small) noticks gmin gmax) ///
		ylabel(, noticks nolabels axis(2)) ///
		yscale(noline alt) yscale(noline alt range(0 200) axis(2))	 ///
		yline(0, lwidth(medthin) lpattern(solid)) ///
		xtitle("Interest in election", size(small)) ///
		xscale(range(0.9 4.1) noline) ///
		xlabel(1 "Very low" 2 "Low" 3 "High" 4 "Very high", labels labsize(small) angle(horizontal) noticks) ///
		title("All issues", margin(bottom)) ///
		legend(off) xsize(3) ysize(4) saving(all, replace)
drop sample - lowerx

* Personally salient issues
xtreg cand_vint prox_cand_sal15 c.prox_cand_sal15#c.voter_interest prox_party15 party_id party_GE2019 cand_lwin i.cand_id, cl(voter_id) fe i(voter_id)
gen sample = e(sample)
margins, dydx(prox_cand_sal15) at(voter_interest = (1(1)4)) post
generate MVZ= _n
replace  MVZ= . if MVZ > 4
gen conbx = _b[prox_cand_sal15:1bn._at] if MVZ == 1
replace conbx = _b[prox_cand_sal15:2._at] if MVZ == 2
replace conbx = _b[prox_cand_sal15:3._at] if MVZ == 3
replace conbx = _b[prox_cand_sal15:4._at] if MVZ == 4
gen consx = _se[prox_cand_sal15:1bn._at] if MVZ == 1
replace consx = _se[prox_cand_sal15:2._at] if MVZ == 2
replace consx = _se[prox_cand_sal15:3._at] if MVZ == 3
replace consx = _se[prox_cand_sal15:4._at] if MVZ == 4
gen ax = 1.96 * consx
gen upperx = conbx + ax
gen lowerx = conbx - ax
sum prox_cand_sal
scalar sd = `r(sd)'
foreach var of varlist conbx consx ax upperx lowerx {
replace `var' = `var' * sd	
}
twoway (hist voter_interest if sample == 1, width(0.25) percent color(gs14) discrete fintensity(100) yaxis(2) ) ///
		(scatter conbx MVZ, mcolor(black) msize(medsmall) msymbol(circle) yaxis(1)) ///
		(rspike lowerx upperx MVZ, lcolor(black) lwidth(medthin) lpattern(solid) yaxis(1)) ///
		, ///
		ytitle("Effect of a standard deviation increase in a" "voter's proximity to a candidate on candidate vote intention", size(small)) ///
		ytitle("", axis(2)) ///
		ylabel(-0.04(0.02)0.06, labsize(small) noticks gmin gmax) ///
		ylabel(, noticks nolabels axis(2)) ///
		yscale(noline alt) yscale(noline alt range(0 200) axis(2))	 ///
		yline(0, lwidth(medthin) lpattern(solid)) ///
		xtitle("Interest in election", size(small)) ///
		xscale(range(0.9 4.1) noline) ///
		xlabel(1 "Very low" 2 "Low" 3 "High" 4 "Very high", labels labsize(small) angle(horizontal) noticks) ///
		title("Personally salient issues", margin(bottom)) ///
		legend(off) xsize(3) ysize(4) saving(salient, replace)
drop sample - lowerx


* Combine graphs
graph combine all.gph salient.gph, scale(1.1)

* Tidy up
erase "all.gph"
erase "salient.gph"





*****************************************
** ROBUSTNESS 4: Two-way Clustered SEs **
*****************************************




* Model 1
reghdfe cand_vint prox_cand, cl(voter_id cand_id) keepsingletons
estimates store m1
	* Number of candidates
	distinct cand_id if e(sample)
	estadd local N_cand `r(ndistinct)'
	estadd local candfe "No"
	estadd local voterfe "No"


* Model 2
reghdfe cand_vint prox_cand prox_party party_id party_GE2019 cand_lwin, absorb(voter_id cand_id) cl(voter_id cand_id) keepsingletons
estimates store m2
	* Number of candidates
	distinct cand_id if e(sample)
	estadd local N_cand `r(ndistinct)'
	estadd local candfe "Yes"
	estadd local voterfe "Yes"	
	
	
* Model 3
gen xz = prox_cand * voter_interest
reghdfe cand_vint prox_cand xz prox_party party_id party_GE2019 cand_lwin, absorb(voter_id cand_id) cl(voter_id cand_id) keepsingletons
estimates store m3
	* Number of candidates
	distinct cand_id if e(sample)
	estadd local N_cand `r(ndistinct)'
	estadd local candfe "Yes"
	estadd local voterfe "Yes"	
drop xz	
	
	
* Model 4
reghdfe cand_vint prox_cand_sal, cl(voter_id cand_id) keepsingletons
estimates store m4
	* Number of candidates
	distinct cand_id if e(sample)
	estadd local N_cand `r(ndistinct)'	
	estadd local candfe "No"
	estadd local voterfe "No"	

	
* Model 5
reghdfe cand_vint prox_cand_sal prox_party party_id party_GE2019 cand_lwin, absorb(voter_id cand_id) cl(voter_id cand_id) keepsingletons
estimates store m5
	* Number of candidates
	distinct cand_id if e(sample)
	estadd local N_cand `r(ndistinct)'
	estadd local candfe "Yes"
	estadd local voterfe "Yes"		


* Model 6
gen xz = prox_cand_sal * voter_interest
reghdfe cand_vint prox_cand_sal xz prox_party party_id party_GE2019 cand_lwin, absorb(voter_id cand_id) cl(voter_id cand_id) keepsingletons
estimates store m6
	* Number of candidates
	distinct cand_id if e(sample)
	estadd local N_cand `r(ndistinct)'
	estadd local candfe "Yes"
	estadd local voterfe "Yes"		
drop xz	


	
	

* Figures
	
* All issues
reghdfe cand_vint prox_cand c.prox_cand#c.voter_interest prox_party party_id party_GE2019 cand_lwin, absorb(voter_id cand_id) cl(voter_id cand_id) keepsingletons
gen sample = e(sample)
margins, dydx(prox_cand) at(voter_interest = (1(1)4)) post
generate MVZ= _n
replace  MVZ= . if MVZ > 4
gen conbx = _b[prox_cand:1bn._at] if MVZ == 1
replace conbx = _b[prox_cand:2._at] if MVZ == 2
replace conbx = _b[prox_cand:3._at] if MVZ == 3
replace conbx = _b[prox_cand:4._at] if MVZ == 4
gen consx = _se[prox_cand:1bn._at] if MVZ == 1
replace consx = _se[prox_cand:2._at] if MVZ == 2
replace consx = _se[prox_cand:3._at] if MVZ == 3
replace consx = _se[prox_cand:4._at] if MVZ == 4
gen ax = 1.96 * consx
gen upperx = conbx + ax
gen lowerx = conbx - ax
sum prox_cand
scalar sd = `r(sd)'
foreach var of varlist conbx consx ax upperx lowerx {
replace `var' = `var' * sd	
}
twoway 	(hist voter_interest if sample == 1, width(0.25) percent color(gs14) discrete fintensity(100) yaxis(2) ) ///
		(scatter conbx MVZ, mcolor(black) msize(medsmall) msymbol(circle) yaxis(1)) ///
		(rspike lowerx upperx MVZ, lcolor(black) lwidth(medthin) lpattern(solid) yaxis(1)) ///
		, ///
		ytitle("Effect of a standard deviation increase in a" "voter's proximity to a candidate on candidate vote intention", size(small)) ///
		ytitle("", axis(2)) ///
		ylabel(-0.06(0.02)0.06, labsize(small) noticks gmin gmax) ///
		ylabel(, noticks nolabels axis(2)) ///
		yscale(noline alt) yscale(noline alt range(0 200) axis(2))	 ///
		yline(0, lwidth(medthin) lpattern(solid)) ///
		xtitle("Interest in election", size(small)) ///
		xscale(range(0.9 4.1) noline) ///
		xlabel(1 "Very low" 2 "Low" 3 "High" 4 "Very high", labels labsize(small) angle(horizontal) noticks) ///
		title("All issues", margin(bottom)) ///
		legend(off) xsize(3) ysize(4) saving(all, replace)
drop sample - lowerx

* Personally salient issues
reghdfe cand_vint prox_cand_sal c.prox_cand_sal#c.voter_interest prox_party party_id party_GE2019 cand_lwin, absorb(voter_id cand_id) cl(voter_id cand_id) keepsingletons
gen sample = e(sample)
margins, dydx(prox_cand_sal) at(voter_interest = (1(1)4)) post
generate MVZ= _n
replace  MVZ= . if MVZ > 4
gen conbx = _b[prox_cand_sal:1bn._at] if MVZ == 1
replace conbx = _b[prox_cand_sal:2._at] if MVZ == 2
replace conbx = _b[prox_cand_sal:3._at] if MVZ == 3
replace conbx = _b[prox_cand_sal:4._at] if MVZ == 4
gen consx = _se[prox_cand_sal:1bn._at] if MVZ == 1
replace consx = _se[prox_cand_sal:2._at] if MVZ == 2
replace consx = _se[prox_cand_sal:3._at] if MVZ == 3
replace consx = _se[prox_cand_sal:4._at] if MVZ == 4
gen ax = 1.96 * consx
gen upperx = conbx + ax
gen lowerx = conbx - ax
sum prox_cand_sal
scalar sd = `r(sd)'
foreach var of varlist conbx consx ax upperx lowerx {
replace `var' = `var' * sd	
}
twoway (hist voter_interest if sample == 1, width(0.25) percent color(gs14) discrete fintensity(100) yaxis(2) ) ///
		(scatter conbx MVZ, mcolor(black) msize(medsmall) msymbol(circle) yaxis(1)) ///
		(rspike lowerx upperx MVZ, lcolor(black) lwidth(medthin) lpattern(solid) yaxis(1)) ///
		, ///
		ytitle("Effect of a standard deviation increase in a" "voter's proximity to a candidate on candidate vote intention", size(small)) ///
		ytitle("", axis(2)) ///
		ylabel(-0.06(0.02)0.06, labsize(small) noticks gmin gmax) ///
		ylabel(, noticks nolabels axis(2)) ///
		yscale(noline alt) yscale(noline alt range(0 200) axis(2))	 ///
		yline(0, lwidth(medthin) lpattern(solid)) ///
		xtitle("Interest in election", size(small)) ///
		xscale(range(0.9 4.1) noline) ///
		xlabel(1 "Very low" 2 "Low" 3 "High" 4 "Very high", labels labsize(small) angle(horizontal) noticks) ///
		title("Personally salient issues", margin(bottom)) ///
		legend(off) xsize(3) ysize(4) saving(salient, replace)
drop sample - lowerx


* Combine graphs
graph combine all.gph salient.gph, scale(1.1)

* Tidy up
erase "all.gph"
erase "salient.gph"









*************************************
** ROBUSTNESS 5: Bootstrapping SEs **
*************************************


* Model 1
reg cand_vint prox_cand, vce(bootstrap, reps(1000) cluster(voter_id) seed(178))
estimates store m1
	* Number of candidates
	distinct cand_id if e(sample)
	estadd local N_cand `r(ndistinct)'


* Model 2
xtreg cand_vint prox_cand prox_party party_id party_GE2019 cand_lwin i.cand_id, vce(bootstrap, reps(1000) seed(178)) cluster(voter_id) fe i(voter_id)
estimates store m2
	* Number of candidates
	distinct cand_id if e(sample)
	estadd local N_cand `r(ndistinct)'

	
* Model 3
gen xz = prox_cand * voter_interest
xtreg cand_vint prox_cand xz prox_party party_id party_GE2019 cand_lwin i.cand_id, vce(bootstrap, reps(1000) seed(178)) cluster(voter_id) fe i(voter_id)
estimates store m3
	* Number of candidates
	distinct cand_id if e(sample)
	estadd local N_cand `r(ndistinct)'
drop xz	
	
	
* Model 4
reg cand_vint prox_cand_sal, vce(bootstrap, reps(1000) cluster(voter_id) seed(178))
estimates store m4
	* Number of candidates
	distinct cand_id if e(sample)
	estadd local N_cand `r(ndistinct)'	

	
* Model 5
xtreg cand_vint prox_cand_sal prox_party party_id party_GE2019 cand_lwin i.cand_id, vce(bootstrap, reps(1000) seed(178)) cluster(voter_id) fe i(voter_id)
estimates store m5
	* Number of candidates
	distinct cand_id if e(sample)
	estadd local N_cand `r(ndistinct)'


* Model 6
gen xz = prox_cand_sal * voter_interest
xtreg cand_vint prox_cand_sal xz prox_party party_id party_GE2019 cand_lwin i.cand_id, vce(bootstrap, reps(1000) seed(178)) cluster(voter_id) fe i(voter_id)
estimates store m6
	* Number of candidates
	distinct cand_id if e(sample)
	estadd local N_cand `r(ndistinct)'
drop xz	




	
* Figures
	
* All issues
xtreg cand_vint prox_cand c.prox_cand#c.voter_interest prox_party party_id party_GE2019 cand_lwin i.cand_id, vce(bootstrap, reps(1000) seed(178)) cluster(voter_id) fe i(voter_id)
gen sample = e(sample)
margins, dydx(prox_cand) at(voter_interest = (1(1)4)) post
generate MVZ= _n
replace  MVZ= . if MVZ > 4
gen conbx = _b[prox_cand:1bn._at] if MVZ == 1
replace conbx = _b[prox_cand:2._at] if MVZ == 2
replace conbx = _b[prox_cand:3._at] if MVZ == 3
replace conbx = _b[prox_cand:4._at] if MVZ == 4
gen consx = _se[prox_cand:1bn._at] if MVZ == 1
replace consx = _se[prox_cand:2._at] if MVZ == 2
replace consx = _se[prox_cand:3._at] if MVZ == 3
replace consx = _se[prox_cand:4._at] if MVZ == 4
gen ax = 1.96 * consx
gen upperx = conbx + ax
gen lowerx = conbx - ax
sum prox_cand
scalar sd = `r(sd)'
foreach var of varlist conbx consx ax upperx lowerx {
replace `var' = `var' * sd	
}
twoway 	(hist voter_interest if sample == 1, width(0.25) percent color(gs14) discrete fintensity(100) yaxis(2) ) ///
		(scatter conbx MVZ, mcolor(black) msize(medsmall) msymbol(circle) yaxis(1)) ///
		(rspike lowerx upperx MVZ, lcolor(black) lwidth(medthin) lpattern(solid) yaxis(1)) ///
		, ///
		ytitle("Effect of a standard deviation increase in a" "voter's proximity to a candidate on candidate vote intention", size(small)) ///
		ytitle("", axis(2)) ///
		ylabel(-0.06(0.02)0.06, labsize(small) noticks gmin gmax) ///
		ylabel(, noticks nolabels axis(2)) ///
		yscale(noline alt) yscale(noline alt range(0 200) axis(2))	 ///
		yline(0, lwidth(medthin) lpattern(solid)) ///
		xtitle("Interest in election", size(small)) ///
		xscale(range(0.9 4.1) noline) ///
		xlabel(1 "Very low" 2 "Low" 3 "High" 4 "Very high", labels labsize(small) angle(horizontal) noticks) ///
		title("All issues", margin(bottom)) ///
		legend(off) xsize(3) ysize(4) saving(all, replace)
drop sample - lowerx

* Personally salient issues
xtreg cand_vint prox_cand_sal c.prox_cand_sal#c.voter_interest prox_party party_id party_GE2019 cand_lwin i.cand_id, vce(bootstrap, reps(1000) seed(178)) cluster(voter_id) fe i(voter_id)
gen sample = e(sample)
margins, dydx(prox_cand_sal) at(voter_interest = (1(1)4)) post
generate MVZ= _n
replace  MVZ= . if MVZ > 4
gen conbx = _b[prox_cand_sal:1bn._at] if MVZ == 1
replace conbx = _b[prox_cand_sal:2._at] if MVZ == 2
replace conbx = _b[prox_cand_sal:3._at] if MVZ == 3
replace conbx = _b[prox_cand_sal:4._at] if MVZ == 4
gen consx = _se[prox_cand_sal:1bn._at] if MVZ == 1
replace consx = _se[prox_cand_sal:2._at] if MVZ == 2
replace consx = _se[prox_cand_sal:3._at] if MVZ == 3
replace consx = _se[prox_cand_sal:4._at] if MVZ == 4
gen ax = 1.96 * consx
gen upperx = conbx + ax
gen lowerx = conbx - ax
sum prox_cand_sal
scalar sd = `r(sd)'
foreach var of varlist conbx consx ax upperx lowerx {
replace `var' = `var' * sd	
}
twoway (hist voter_interest if sample == 1, width(0.25) percent color(gs14) discrete fintensity(100) yaxis(2) ) ///
		(scatter conbx MVZ, mcolor(black) msize(medsmall) msymbol(circle) yaxis(1)) ///
		(rspike lowerx upperx MVZ, lcolor(black) lwidth(medthin) lpattern(solid) yaxis(1)) ///
		, ///
		ytitle("Effect of a standard deviation increase in a" "voter's proximity to a candidate on candidate vote intention", size(small)) ///
		ytitle("", axis(2)) ///
		ylabel(-0.06(0.02)0.06, labsize(small) noticks gmin gmax) ///
		ylabel(, noticks nolabels axis(2)) ///
		yscale(noline alt) yscale(noline alt range(0 200) axis(2))	 ///
		yline(0, lwidth(medthin) lpattern(solid)) ///
		xtitle("Interest in election", size(small)) ///
		xscale(range(0.9 4.1) noline) ///
		xlabel(1 "Very low" 2 "Low" 3 "High" 4 "Very high", labels labsize(small) angle(horizontal) noticks) ///
		title("Personally salient issues", margin(bottom)) ///
		legend(off) xsize(3) ysize(4) saving(salient, replace)
drop sample - lowerx


* Combine graphs
graph combine all.gph salient.gph, scale(1.1)

* Tidy up
erase "all.gph"
erase "salient.gph"	





	
*************************************
** ROBUSTNESS 6: Conditional Logit **
*************************************


* Model 1
logit cand_vint prox_cand, cl(voter_id)
estimates store m1
	* Number of candidates
	distinct cand_id if e(sample)
	estadd local N_cand `r(ndistinct)'

* Model 2
clogit cand_vint prox_cand prox_party party_id party_GE2019 cand_lwin cand_incumb cand_female cand_local, group(voter_id) cluster(voter_id)
estimates store m2
	* Number of candidates
	distinct cand_id if e(sample)
	estadd local N_cand `r(ndistinct)'
	
* Model 3
gen xz = prox_cand * voter_interest
clogit cand_vint prox_cand xz prox_party party_id party_GE2019 cand_lwin cand_incumb cand_female cand_local, group(voter_id) cluster(voter_id)
estimates store m3
	* Number of candidates
	distinct cand_id if e(sample)
	estadd local N_cand `r(ndistinct)'
drop xz	
	
	
* Model 4
logit cand_vint prox_cand_sal, cl(voter_id)
estimates store m4
	* Number of candidates
	distinct cand_id if e(sample)
	estadd local N_cand `r(ndistinct)'

	
* Model 5
clogit cand_vint prox_cand_sal prox_party party_id party_GE2019 cand_lwin cand_incumb cand_female cand_local, group(voter_id) cluster(voter_id)
estimates store m5
	* Number of candidates
	distinct cand_id if e(sample)
	estadd local N_cand `r(ndistinct)'


* Model 6
gen xz = prox_cand_sal * voter_interest
clogit cand_vint prox_cand_sal xz prox_party party_id party_GE2019 cand_lwin cand_incumb cand_female cand_local, group(voter_id) cluster(voter_id)
estimates store m6
	* Number of candidates
	distinct cand_id if e(sample)
	estadd local N_cand `r(ndistinct)'
drop xz	



	
	
	
* Figures
	
* All issues
clogit cand_vint c.prox_cand c.prox_cand#c.voter_interest prox_party party_id party_GE2019 cand_lwin cand_incumb cand_female cand_local, group(voter_id) cluster(voter_id)
gen sample = e(sample)
margins, dydx(prox_cand) at(voter_interest = (1(1)4)) post predict(xb)
generate MVZ= _n
replace  MVZ= . if MVZ > 4
gen conbx = _b[prox_cand:1bn._at] if MVZ == 1
replace conbx = _b[prox_cand:2._at] if MVZ == 2
replace conbx = _b[prox_cand:3._at] if MVZ == 3
replace conbx = _b[prox_cand:4._at] if MVZ == 4
gen consx = _se[prox_cand:1bn._at] if MVZ == 1
replace consx = _se[prox_cand:2._at] if MVZ == 2
replace consx = _se[prox_cand:3._at] if MVZ == 3
replace consx = _se[prox_cand:4._at] if MVZ == 4
gen ax = 1.96 * consx
gen upperx = conbx + ax
gen lowerx = conbx - ax
sum prox_cand
scalar sd = `r(sd)'
foreach var of varlist conbx consx ax upperx lowerx {
replace `var' = `var' * sd	
}
twoway 	(hist voter_interest if sample == 1, width(0.25) percent color(gs14) discrete fintensity(100) yaxis(2) ) ///
		(scatter conbx MVZ, mcolor(black) msize(medsmall) msymbol(circle) yaxis(1)) ///
		(rspike lowerx upperx MVZ, lcolor(black) lwidth(medthin) lpattern(solid) yaxis(1)) ///
		, ///
		ytitle("Effect of a standard deviation increase in a voter's proximity" "to a candidate on candidate vote intention (logged odds)", size(small)) ///
		ytitle("", axis(2)) ///
		ylabel(-1(1)2, labsize(small) noticks gmin gmax) ///
		ylabel(, noticks nolabels axis(2)) ///
		yscale(noline alt) yscale(noline alt range(0 200) axis(2))	 ///
		yline(0, lwidth(medthin) lpattern(solid)) ///
		xtitle("Interest in election", size(small)) ///
		xscale(range(0.9 4.1) noline) ///
		xlabel(1 "Very low" 2 "Low" 3 "High" 4 "Very high", labels labsize(small) angle(horizontal) noticks) ///
		title("All issues", margin(bottom)) ///
		legend(off) xsize(3) ysize(4) saving(all, replace)
drop sample - lowerx	
	
	
* Personally salient issues
clogit cand_vint c.prox_cand_sal c.prox_cand_sal#c.voter_interest prox_party party_id party_GE2019 cand_lwin cand_incumb cand_female cand_local, group(voter_id) cluster(voter_id)
gen sample = e(sample)
margins, dydx(prox_cand_sal) at(voter_interest = (1(1)4)) post predict(xb)
generate MVZ= _n
replace  MVZ= . if MVZ > 4
gen conbx = _b[prox_cand_sal:1bn._at] if MVZ == 1
replace conbx = _b[prox_cand_sal:2._at] if MVZ == 2
replace conbx = _b[prox_cand_sal:3._at] if MVZ == 3
replace conbx = _b[prox_cand_sal:4._at] if MVZ == 4
gen consx = _se[prox_cand_sal:1bn._at] if MVZ == 1
replace consx = _se[prox_cand_sal:2._at] if MVZ == 2
replace consx = _se[prox_cand_sal:3._at] if MVZ == 3
replace consx = _se[prox_cand_sal:4._at] if MVZ == 4
gen ax = 1.96 * consx
gen upperx = conbx + ax
gen lowerx = conbx - ax
sum prox_cand_sal
scalar sd = `r(sd)'
foreach var of varlist conbx consx ax upperx lowerx {
replace `var' = `var' * sd	
}
twoway (hist voter_interest if sample == 1, width(0.25) percent color(gs14) discrete fintensity(100) yaxis(2) ) ///
		(scatter conbx MVZ, mcolor(black) msize(medsmall) msymbol(circle) yaxis(1)) ///
		(rspike lowerx upperx MVZ, lcolor(black) lwidth(medthin) lpattern(solid) yaxis(1)) ///
		, ///
		ytitle("Effect of a standard deviation increase in a voter's proximity" "to a candidate on candidate vote intention (logged odds)", size(small)) ///
		ytitle("", axis(2)) ///
		ylabel(-1(1)2, labsize(small) noticks gmin gmax) ///
		ylabel(, noticks nolabels axis(2)) ///
		yscale(noline alt) yscale(noline alt range(0 200) axis(2))	 ///
		yline(0, lwidth(medthin) lpattern(solid)) ///
		xtitle("Interest in election", size(small)) ///
		xscale(range(0.9 4.1) noline) ///
		xlabel(1 "Very low" 2 "Low" 3 "High" 4 "Very high", labels labsize(small) angle(horizontal) noticks) ///
		title("Personally salient issues", margin(bottom)) ///
		legend(off) xsize(3) ysize(4) saving(salient, replace)
drop sample - lowerx


* Combine graphs
graph combine all.gph salient.gph, scale(1.1)

* Tidy up
erase "all.gph"
erase "salient.gph"







*************************************
** ROBUSTNESS 7: Double de-meaning **
*************************************


* All issues
* Normal FE model
gen xz = prox_cand * voter_interest
xtreg cand_vint prox_cand xz prox_party party_id party_GE2019 cand_lwin i.cand_id, cl(voter_id) fe i(voter_id)
gen sample = e(sample)
* Double de-meaned interaction
foreach var of varlist prox_cand voter_interest {
egen mean`var' = mean(`var') if sample == 1, by(cand_id)
gen dm`var' = `var'- mean`var' 
}
gen dmxz = dmprox_cand * dmvoter_interest
xtreg cand_vint prox_cand dmxz prox_party party_id party_GE2019 cand_lwin i.cand_id, cl(voter_id) fe i(voter_id)
estimates store m1
	* Number of candidates
	distinct cand_id if e(sample)
	estadd local N_cand `r(ndistinct)'
* Tidy up
drop xz - dmxz



* Salient issues
* Normal FE model
gen xz = prox_cand_sal * voter_interest
xtreg cand_vint prox_cand_sal xz prox_party party_id party_GE2019 cand_lwin i.cand_id, cl(voter_id) fe i(voter_id)
gen sample = e(sample)
* Double de-meaned interaction
foreach var of varlist prox_cand_sal voter_interest {
egen mean`var' = mean(`var') if sample == 1, by(cand_id)
gen dm`var' = `var'- mean`var' 
}
gen dmxz = dmprox_cand_sal * dmvoter_interest
xtreg cand_vint prox_cand_sal dmxz prox_party party_id party_GE2019 cand_lwin i.cand_id, cl(voter_id) fe i(voter_id)
estimates store m2
	* Number of candidates
	distinct cand_id if e(sample)
	estadd local N_cand `r(ndistinct)'
* Tidy up
drop xz - dmxz



	
* Figure

* All issues
* Sample identifier
xtreg cand_vint prox_cand c.prox_cand#c.voter_interest prox_party party_id party_GE2019 cand_lwin i.cand_id, cl(voter_id) fe i(voter_id)
gen sample = e(sample)
* Double de-meaned interaction
foreach var of varlist prox_cand voter_interest {
egen mean`var' = mean(`var') if sample == 1, by(cand_id)
gen dm`var' = `var'- mean`var' 
}
xtreg cand_vint dmprox_cand c.dmprox_cand#c.dmvoter_interest prox_party party_id party_GE2019 cand_lwin i.cand_id, cl(voter_id) fe i(voter_id)
sum dmvoter_interest if sample == 1
* Margins
margins, dydx(dmprox_cand) at(dmvoter_interest = (-2.2(1)0.8)) post
generate MVZ= _n
replace  MVZ= . if MVZ > 4
gen conbx = _b[dmprox_cand:1bn._at] if MVZ == 1
replace conbx = _b[dmprox_cand:2._at] if MVZ == 2
replace conbx = _b[dmprox_cand:3._at] if MVZ == 3
replace conbx = _b[dmprox_cand:4._at] if MVZ == 4
gen consx = _se[dmprox_cand:1bn._at] if MVZ == 1
replace consx = _se[dmprox_cand:2._at] if MVZ == 2
replace consx = _se[dmprox_cand:3._at] if MVZ == 3
replace consx = _se[dmprox_cand:4._at] if MVZ == 4
replace MVZ = MVZ -3.2
gen ax = 1.96 * consx
gen upperx = conbx + ax
gen lowerx = conbx - ax
sum prox_cand
scalar sd = `r(sd)'
foreach var of varlist conbx consx ax upperx lowerx {
replace `var' = `var' * sd	
}
* Graph
twoway 	(hist dmvoter_interest if sample == 1, percent color(gs14) fintensity(100) yaxis(2) ) ///
		(scatter conbx MVZ, mcolor(black) msize(medsmall) msymbol(circle) yaxis(1)) ///
		(rspike lowerx upperx MVZ, lcolor(black) lwidth(medthin) lpattern(solid) yaxis(1)) ///
		, ///
		ytitle("Effect of a standard deviation increase in a" "voter's proximity to a candidate on candidate vote intention", size(small)) ///
		ytitle("", axis(2)) ///
		ylabel(-0.04(0.02)0.06, labsize(small) noticks gmin gmax) ///
		ylabel(, noticks nolabels axis(2)) ///
		yscale(noline alt) yscale(noline alt range(0 100) axis(2))	 ///
		yline(0, lwidth(medthin) lpattern(solid)) ///
		xtitle("Interest in election (de-meaned)", size(small)) ///
		xscale(range(-3.1 1.1) noline) ///
		xlabel(, labels labsize(small) angle(horizontal) noticks) ///
		title("All issues") ///
		legend(off) xsize(3) ysize(4) saving(all, replace)
drop sample - lowerx



* Personally salient issues
* Normal FE model
xtreg cand_vint prox_cand_sal c.prox_cand_sal#c.voter_interest prox_party party_id party_GE2019 cand_lwin i.cand_id, cl(voter_id) fe i(voter_id)
gen sample = e(sample)
* Double de-meaned interaction
foreach var of varlist prox_cand_sal voter_interest {
egen mean`var' = mean(`var') if sample == 1, by(cand_id)
gen dm`var' = `var'- mean`var' 
}
xtreg cand_vint dmprox_cand_sal c.dmprox_cand_sal#c.dmvoter_interest prox_party party_id party_GE2019 cand_lwin i.cand_id, cl(voter_id) fe i(voter_id)
sum dmvoter_interest if sample == 1
* Margins
margins, dydx(dmprox_cand_sal) at(dmvoter_interest = (-2.2(1)0.8)) post
generate MVZ= _n
replace  MVZ= . if MVZ > 4
gen conbx = _b[dmprox_cand_sal:1bn._at] if MVZ == 1
replace conbx = _b[dmprox_cand_sal:2._at] if MVZ == 2
replace conbx = _b[dmprox_cand_sal:3._at] if MVZ == 3
replace conbx = _b[dmprox_cand_sal:4._at] if MVZ == 4
gen consx = _se[dmprox_cand_sal:1bn._at] if MVZ == 1
replace consx = _se[dmprox_cand_sal:2._at] if MVZ == 2
replace consx = _se[dmprox_cand_sal:3._at] if MVZ == 3
replace consx = _se[dmprox_cand_sal:4._at] if MVZ == 4
replace MVZ = MVZ -3.2
gen ax = 1.96 * consx
gen upperx = conbx + ax
gen lowerx = conbx - ax
sum prox_cand_sal
scalar sd = `r(sd)'
foreach var of varlist conbx consx ax upperx lowerx {
replace `var' = `var' * sd	
}
twoway 	(hist dmvoter_interest if sample == 1, percent color(gs14) fintensity(100) yaxis(2) ) ///
		(scatter conbx MVZ, mcolor(black) msize(medsmall) msymbol(circle) yaxis(1)) ///
		(rspike lowerx upperx MVZ, lcolor(black) lwidth(medthin) lpattern(solid) yaxis(1)) ///
		, ///
		ytitle("Effect of a standard deviation increase in a" "voter's proximity to a candidate on candidate vote intention", size(small)) ///
		ytitle("", axis(2)) ///
		ylabel(-0.04(0.02)0.06, labsize(small) noticks gmin gmax) ///
		ylabel(, noticks nolabels axis(2)) ///
		yscale(noline alt) yscale(noline alt range(0 100) axis(2))	 ///
		yline(0, lwidth(medthin) lpattern(solid)) ///
		xtitle("Interest in election (de-meaned)", size(small)) ///
		xscale(range(-3.1 1.1) noline) ///
		xlabel(, labels labsize(small) angle(horizontal) noticks) ///
		title("Personally salient issues") ///
		legend(off) xsize(3) ysize(4) saving(salient, replace)
drop sample - lowerx


* Combine graphs
graph combine all.gph salient.gph, scale(1.1)

* Tidy up
erase "all.gph"
erase "salient.gph"






***********************************************
** ROBUSTNESS 8: Familiarity with candidates **
***********************************************


* Model 1
gen xz = prox_cand * cand_knowl
xtreg cand_vint prox_cand xz prox_party party_id party_GE2019 cand_lwin i.cand_id, cl(voter_id) fe i(voter_id)
estimates store m1
	* Number of candidates
	distinct cand_id if e(sample)
	estadd local N_cand `r(ndistinct)'
drop xz

* Model 2
gen xz = prox_cand_sal * cand_knowl
xtreg cand_vint prox_cand_sal xz prox_party party_id party_GE2019 cand_lwin i.cand_id, cl(voter_id) fe i(voter_id)
estimates store m2
	* Number of candidates
	distinct cand_id if e(sample)
	estadd local N_cand `r(ndistinct)'
drop xz	



	
	
	
* Figure

* All issues
xtreg cand_vint prox_cand c.prox_cand#c.cand_knowl prox_party party_id party_GE2019 cand_lwin i.cand_id, cl(voter_id) fe i(voter_id)
gen sample = e(sample)
margins, dydx(prox_cand) at(cand_knowl = (1(1)4)) post
generate MVZ= _n
replace  MVZ= . if MVZ > 4
gen conbx = _b[prox_cand:1bn._at] if MVZ == 1
replace conbx = _b[prox_cand:2._at] if MVZ == 2
replace conbx = _b[prox_cand:3._at] if MVZ == 3
replace conbx = _b[prox_cand:4._at] if MVZ == 4
gen consx = _se[prox_cand:1bn._at] if MVZ == 1
replace consx = _se[prox_cand:2._at] if MVZ == 2
replace consx = _se[prox_cand:3._at] if MVZ == 3
replace consx = _se[prox_cand:4._at] if MVZ == 4
gen ax = 1.96 * consx
gen upperx = conbx + ax
gen lowerx = conbx - ax
sum prox_cand
scalar sd = `r(sd)'
foreach var of varlist conbx consx ax upperx lowerx {
replace `var' = `var' * sd	
}
twoway 	(hist cand_knowl if sample == 1, width(0.25) percent color(gs14) discrete fintensity(100) yaxis(2) ) ///
		(scatter conbx MVZ, mcolor(black) msize(medsmall) msymbol(circle) yaxis(1)) ///
		(rspike lowerx upperx MVZ, lcolor(black) lwidth(medthin) lpattern(solid) yaxis(1)) ///
		, ///
		ytitle("Effect of a standard deviation increase in a" "voter's proximity to a candidate on candidate vote intention", size(small)) ///
		ytitle("", axis(2)) ///
		ylabel(-0.04(0.02)0.06, labsize(small) noticks gmin gmax) ///
		ylabel(, noticks nolabels axis(2)) ///
		yscale(noline alt) yscale(noline alt range(0 200) axis(2))	 ///
		yline(0, lwidth(medthin) lpattern(solid)) ///
		xtitle("Familiarity with candidates", size(small)) ///
		xscale(range(0.9 4.1) noline) ///
		xlabel(1 "Very low" 2 "Low" 3 "High" 4 "Very high", labels labsize(small) angle(horizontal) noticks) ///
		title("All issues") ///
		legend(off) xsize(3) ysize(4) saving(all, replace)
drop sample - lowerx

* Personally salient issues
xtreg cand_vint prox_cand_sal c.prox_cand_sal#c.cand_knowl prox_party party_id party_GE2019 cand_lwin i.cand_id, cl(voter_id) fe i(voter_id)
gen sample = e(sample)
margins, dydx(prox_cand_sal) at(cand_knowl = (1(1)4)) post
generate MVZ= _n
replace  MVZ= . if MVZ > 4
gen conbx = _b[prox_cand_sal:1bn._at] if MVZ == 1
replace conbx = _b[prox_cand_sal:2._at] if MVZ == 2
replace conbx = _b[prox_cand_sal:3._at] if MVZ == 3
replace conbx = _b[prox_cand_sal:4._at] if MVZ == 4
gen consx = _se[prox_cand_sal:1bn._at] if MVZ == 1
replace consx = _se[prox_cand_sal:2._at] if MVZ == 2
replace consx = _se[prox_cand_sal:3._at] if MVZ == 3
replace consx = _se[prox_cand_sal:4._at] if MVZ == 4
gen ax = 1.96 * consx
gen upperx = conbx + ax
gen lowerx = conbx - ax
sum prox_cand_sal
scalar sd = `r(sd)'
foreach var of varlist conbx consx ax upperx lowerx {
replace `var' = `var' * sd	
}
twoway 	(hist cand_knowl if sample == 1, width(0.25) percent color(gs14) discrete fintensity(100) yaxis(2) ) ///
		(scatter conbx MVZ, mcolor(black) msize(medsmall) msymbol(circle) yaxis(1)) ///
		(rspike lowerx upperx MVZ, lcolor(black) lwidth(medthin) lpattern(solid) yaxis(1)) ///
		, ///
		ytitle("Effect of a standard deviation increase in a" "voter's proximity to a candidate on candidate vote intention", size(small)) ///
		ytitle("", axis(2)) ///
		ylabel(-0.04(0.02)0.06, labsize(small) noticks gmin gmax) ///
		ylabel(, noticks nolabels axis(2)) ///
		yscale(noline alt) yscale(noline alt range(0 200) axis(2))	 ///
		yline(0, lwidth(medthin) lpattern(solid)) ///
		xtitle("Familiarity with candidates", size(small)) ///
		xscale(range(0.9 4.1) noline) ///
		xlabel(1 "Very low" 2 "Low" 3 "High" 4 "Very high", labels labsize(small) angle(horizontal) noticks) ///
		title("Personally salient issues") ///
		legend(off) xsize(3) ysize(4) saving(salient, replace)
drop MVZ - lowerx


* Combine graphs
graph combine all.gph salient.gph, scale(1.1)

* Tidy up
erase "all.gph"
erase "salient.gph"






********************************************************
** ROBUSTNESS 9: No data cleaning/sample restrictions **
********************************************************

use "WLS21_main.dta", replace
append using "WLS21_dirty.dta"


* Model 1
reg cand_vint prox_cand, cl(voter_id)
estimates store m1
	* Number of candidates
	distinct cand_id if e(sample)
	estadd local N_cand `r(ndistinct)'


* Model 2
xtreg cand_vint prox_cand prox_party party_id party_GE2019 cand_lwin i.cand_id, cl(voter_id) fe i(voter_id)
estimates store m2
	* Number of candidates
	distinct cand_id if e(sample)
	estadd local N_cand `r(ndistinct)'

	
* Model 3
gen xz = prox_cand * voter_interest
xtreg cand_vint prox_cand xz prox_party party_id party_GE2019 cand_lwin i.cand_id, cl(voter_id) fe i(voter_id)
estimates store m3
	* Number of candidates
	distinct cand_id if e(sample)
	estadd local N_cand `r(ndistinct)'
drop xz	
	
	
* Model 4
reg cand_vint prox_cand_sal, cl(voter_id)
estimates store m4
	* Number of candidates
	distinct cand_id if e(sample)
	estadd local N_cand `r(ndistinct)'	

	
* Model 5
xtreg cand_vint prox_cand_sal prox_party party_id party_GE2019 cand_lwin i.cand_id, cl(voter_id) fe i(voter_id)
estimates store m5
	* Number of candidates
	distinct cand_id if e(sample)
	estadd local N_cand `r(ndistinct)'


* Model 6
gen xz = prox_cand_sal * voter_interest
xtreg cand_vint prox_cand_sal xz prox_party party_id party_GE2019 cand_lwin i.cand_id, cl(voter_id) fe i(voter_id)
estimates store m6
	* Number of candidates
	distinct cand_id if e(sample)
	estadd local N_cand `r(ndistinct)'
drop xz	


	


* Figure


* All issues
xtreg cand_vint prox_cand c.prox_cand#c.voter_interest prox_party party_id party_GE2019 cand_lwin i.cand_id, cl(voter_id) fe i(voter_id)
gen sample = e(sample)
margins, dydx(prox_cand) at(voter_interest = (1(1)4)) post
generate MVZ= _n
replace  MVZ= . if MVZ > 4
gen conbx = _b[prox_cand:1bn._at] if MVZ == 1
replace conbx = _b[prox_cand:2._at] if MVZ == 2
replace conbx = _b[prox_cand:3._at] if MVZ == 3
replace conbx = _b[prox_cand:4._at] if MVZ == 4
gen consx = _se[prox_cand:1bn._at] if MVZ == 1
replace consx = _se[prox_cand:2._at] if MVZ == 2
replace consx = _se[prox_cand:3._at] if MVZ == 3
replace consx = _se[prox_cand:4._at] if MVZ == 4
gen ax = 1.96 * consx
gen upperx = conbx + ax
gen lowerx = conbx - ax
sum prox_cand
scalar sd = `r(sd)'
foreach var of varlist conbx consx ax upperx lowerx {
replace `var' = `var' * sd	
}
twoway 	(hist voter_interest if sample == 1, width(0.25) percent color(gs14) discrete fintensity(100) yaxis(2) ) ///
		(scatter conbx MVZ, mcolor(black) msize(medsmall) msymbol(circle) yaxis(1)) ///
		(rspike lowerx upperx MVZ, lcolor(black) lwidth(medthin) lpattern(solid) yaxis(1)) ///
		, ///
		ytitle("Effect of a standard deviation increase in a" "voter's proximity to a candidate on candidate vote intention", size(small)) ///
		ytitle("", axis(2)) ///
		ylabel(-0.06(0.02)0.06, labsize(small) noticks gmin gmax) ///
		ylabel(, noticks nolabels axis(2)) ///
		yscale(noline alt) yscale(noline alt range(0 200) axis(2))	 ///
		yline(0, lwidth(medthin) lpattern(solid)) ///
		xtitle("Interest in election", size(small)) ///
		xscale(range(0.9 4.1) noline) ///
		xlabel(1 "Very low" 2 "Low" 3 "High" 4 "Very high", labels labsize(small) angle(horizontal) noticks) ///
		title("All issues", margin(bottom)) ///
		legend(off) xsize(3) ysize(4) saving(all, replace)
drop sample - lowerx

* Personally salient issues
xtreg cand_vint prox_cand_sal c.prox_cand_sal#c.voter_interest prox_party party_id party_GE2019 cand_lwin i.cand_id, cl(voter_id) fe i(voter_id)
gen sample = e(sample)
margins, dydx(prox_cand_sal) at(voter_interest = (1(1)4)) post
generate MVZ= _n
replace  MVZ= . if MVZ > 4
gen conbx = _b[prox_cand_sal:1bn._at] if MVZ == 1
replace conbx = _b[prox_cand_sal:2._at] if MVZ == 2
replace conbx = _b[prox_cand_sal:3._at] if MVZ == 3
replace conbx = _b[prox_cand_sal:4._at] if MVZ == 4
gen consx = _se[prox_cand_sal:1bn._at] if MVZ == 1
replace consx = _se[prox_cand_sal:2._at] if MVZ == 2
replace consx = _se[prox_cand_sal:3._at] if MVZ == 3
replace consx = _se[prox_cand_sal:4._at] if MVZ == 4
gen ax = 1.96 * consx
gen upperx = conbx + ax
gen lowerx = conbx - ax
sum prox_cand_sal
scalar sd = `r(sd)'
foreach var of varlist conbx consx ax upperx lowerx {
replace `var' = `var' * sd	
}
twoway (hist voter_interest if sample == 1, width(0.25) percent color(gs14) discrete fintensity(100) yaxis(2) ) ///
		(scatter conbx MVZ, mcolor(black) msize(medsmall) msymbol(circle) yaxis(1)) ///
		(rspike lowerx upperx MVZ, lcolor(black) lwidth(medthin) lpattern(solid) yaxis(1)) ///
		, ///
		ytitle("Effect of a standard deviation increase in a" "voter's proximity to a candidate on candidate vote intention", size(small)) ///
		ytitle("", axis(2)) ///
		ylabel(-0.06(0.02)0.06, labsize(small) noticks gmin gmax) ///
		ylabel(, noticks nolabels axis(2)) ///
		yscale(noline alt) yscale(noline alt range(0 200) axis(2))	 ///
		yline(0, lwidth(medthin) lpattern(solid)) ///
		xtitle("Interest in election", size(small)) ///
		xscale(range(0.9 4.1) noline) ///
		xlabel(1 "Very low" 2 "Low" 3 "High" 4 "Very high", labels labsize(small) angle(horizontal) noticks) ///
		title("Personally salient issues", margin(bottom)) ///
		legend(off) xsize(3) ysize(4) saving(salient, replace)
drop sample - lowerx


* Combine graphs
graph combine all.gph salient.gph, scale(1.1)

* Tidy up
erase "all.gph"
erase "salient.gph"






******************************************
** ADDITIONAL ANALYSIS 1: By issue area **
******************************************


use "WLS21_main.dta", replace


* Average effects
xtreg cand_vint prox_cand_eco prox_party party_id party_GE2019 cand_lwin i.cand_id, cl(voter_id) fe i(voter_id)
estimates store m1
	* Number of candidates
	distinct cand_id if e(sample)
	estadd local N_cand `r(ndistinct)'

xtreg cand_vint prox_cand_hsc prox_party party_id party_GE2019 cand_lwin i.cand_id, cl(voter_id) fe i(voter_id)
estimates store m2
	* Number of candidates
	distinct cand_id if e(sample)
	estadd local N_cand `r(ndistinct)'

xtreg cand_vint prox_cand_env prox_party party_id party_GE2019 cand_lwin i.cand_id, cl(voter_id) fe i(voter_id)
estimates store m3
	* Number of candidates
	distinct cand_id if e(sample)
	estadd local N_cand `r(ndistinct)'

xtreg cand_vint prox_cand_edu prox_party party_id party_GE2019 cand_lwin i.cand_id, cl(voter_id) fe i(voter_id)
estimates store m4
	* Number of candidates
	distinct cand_id if e(sample)
	estadd local N_cand `r(ndistinct)'

xtreg cand_vint prox_cand_lcu prox_party party_id party_GE2019 cand_lwin i.cand_id, cl(voter_id) fe i(voter_id)
estimates store m5
	* Number of candidates
	distinct cand_id if e(sample)
	estadd local N_cand `r(ndistinct)'

xtreg cand_vint prox_cand_wls prox_party party_id party_GE2019 cand_lwin i.cand_id, cl(voter_id) fe i(voter_id)
estimates store m6
	* Number of candidates
	distinct cand_id if e(sample)
	estadd local N_cand `r(ndistinct)'
    
xtreg cand_vint prox_cand_eco prox_cand_hsc prox_cand_env prox_cand_edu prox_cand_lcu prox_cand_wls prox_party party_id party_GE2019 cand_lwin i.cand_id, cl(voter_id) fe i(voter_id)
estimates store m7
	* Number of candidates
	distinct cand_id if e(sample)
	estadd local N_cand `r(ndistinct)'




	
*****************************************************************
** ADDITIONAL ANALYSIS 2: By issue area including interactions **
*****************************************************************
	
* Interactions
xtreg cand_vint prox_cand_eco c.prox_cand_eco#i.mii_eco prox_party party_id party_GE2019 cand_lwin i.cand_id, cl(voter_id) fe i(voter_id)
estimates store m1
	* Number of candidates
	distinct cand_id if e(sample)
	estadd local N_cand `r(ndistinct)'

xtreg cand_vint prox_cand_hsc c.prox_cand_hsc#i.mii_hsc prox_party party_id party_GE2019 cand_lwin i.cand_id, cl(voter_id) fe i(voter_id)
estimates store m2
	* Number of candidates
	distinct cand_id if e(sample)
	estadd local N_cand `r(ndistinct)'

xtreg cand_vint prox_cand_env c.prox_cand_env#i.mii_env prox_party party_id party_GE2019 cand_lwin i.cand_id, cl(voter_id) fe i(voter_id)
estimates store m3
	* Number of candidates
	distinct cand_id if e(sample)
	estadd local N_cand `r(ndistinct)'

xtreg cand_vint prox_cand_edu c.prox_cand_edu#i.mii_edu prox_party party_id party_GE2019 cand_lwin i.cand_id, cl(voter_id) fe i(voter_id)
estimates store m4
	* Number of candidates
	distinct cand_id if e(sample)
	estadd local N_cand `r(ndistinct)'

xtreg cand_vint prox_cand_lcu c.prox_cand_lcu#i.mii_lcu prox_party party_id party_GE2019 cand_lwin i.cand_id, cl(voter_id) fe i(voter_id)
estimates store m5
	* Number of candidates
	distinct cand_id if e(sample)
	estadd local N_cand `r(ndistinct)'
	
xtreg cand_vint prox_cand_wls c.prox_cand_wls#i.mii_wls prox_party party_id party_GE2019 cand_lwin i.cand_id, cl(voter_id) fe i(voter_id)
estimates store m6
	* Number of candidates
	distinct cand_id if e(sample)
	estadd local N_cand `r(ndistinct)'

xtreg cand_vint prox_cand_eco c.prox_cand_eco#i.mii_eco prox_cand_hsc c.prox_cand_hsc#i.mii_hsc prox_cand_env c.prox_cand_env#i.mii_env prox_cand_edu c.prox_cand_edu#i.mii_edu  prox_cand_lcu c.prox_cand_lcu#i.mii_lcu prox_cand_wls c.prox_cand_wls#i.mii_wls prox_party party_id party_GE2019 cand_lwin i.cand_id, cl(voter_id) fe i(voter_id)
estimates store m7
	* Number of candidates
	distinct cand_id if e(sample)
	estadd local N_cand `r(ndistinct)'


	
* Figure (based off model 7)
foreach pa in eco hsc env edu lcu wls {
xtreg cand_vint prox_cand_eco c.prox_cand_eco#i.mii_eco prox_cand_hsc c.prox_cand_hsc#i.mii_hsc prox_cand_env c.prox_cand_env#i.mii_env prox_cand_edu c.prox_cand_edu#i.mii_edu  prox_cand_lcu c.prox_cand_lcu#i.mii_lcu prox_cand_wls c.prox_cand_wls#i.mii_wls prox_party party_id party_GE2019 cand_lwin i.cand_id, cl(voter_id) fe i(voter_id)
gen sample = e(sample)
margins, dydx(prox_cand_`pa') at(mii_`pa' = (0(1)1)) post
generate MVZ= _n - 1
replace  MVZ= . if MVZ > 1
gen conbx = _b[prox_cand_`pa':1bn._at] if MVZ == 0
replace conbx = _b[prox_cand_`pa':2._at] if MVZ == 1
gen consx = _se[prox_cand_`pa':1bn._at] if MVZ == 0
replace consx = _se[prox_cand_`pa':2._at] if MVZ == 1
gen ax = 1.96 * consx
gen upperx = conbx + ax
gen lowerx = conbx - ax
sum prox_cand_`pa'
scalar sd = `r(sd)'
foreach var of varlist conbx consx ax upperx lowerx {
replace `var' = `var' * sd	
}
twoway 	(hist mii_`pa' if sample == 1, width(0.25) percent color(gs14) discrete fintensity(100) yaxis(2) ) ///
		(scatter conbx MVZ, mcolor(black) msize(medsmall) msymbol(circle) yaxis(1)) ///
		(rspike lowerx upperx MVZ, lcolor(black) lwidth(medthin) lpattern(solid) yaxis(1)) ///
		, ///
		ytitle("Effect of proximity to candidate", size(small)) ///
		ytitle("", axis(2)) ///
		ylabel(-0.06(0.02)0.08, labsize(small) noticks gmin gmax) ///
		ylabel(, noticks nolabels axis(2)) ///
		yscale(noline alt) yscale(noline alt range(0 400) axis(2))	 ///
		yline(0, lwidth(medthin) lpattern(solid)) ///
		xtitle("MII = `pa'", size(small)) ///
		xscale(range(-0.5 1.5) noline) ///
		xlabel(0 "No" 1 "Yes", labels labsize(small) angle(horizontal) noticks) ///
		title("`pa'", margin(bottom)) ///
		legend(off) xsize(3) ysize(4) saving(`pa', replace)
drop sample - lowerx
}


* Combine graphs
graph combine eco.gph hsc.gph env.gph edu.gph lcu.gph wls.gph, altshrink scale(1.5) rows(2) xsize(9) ysize(8)
gr_edit .plotregion1.graph1.title.text = {}
gr_edit .plotregion1.graph1.title.text.Arrpush "Economy"
gr_edit .plotregion1.graph1.xaxis1.title.text = {}
gr_edit .plotregion1.graph1.xaxis1.title.text.Arrpush "MII = economy"

gr_edit .plotregion1.graph2.title.text = {}
gr_edit .plotregion1.graph2.title.text.Arrpush "Health & social care"
gr_edit .plotregion1.graph2.xaxis1.title.text = {}
gr_edit .plotregion1.graph2.xaxis1.title.text.Arrpush "MII = health & social care"

gr_edit .plotregion1.graph3.title.text = {}
gr_edit .plotregion1.graph3.title.text.Arrpush "Environment"
gr_edit .plotregion1.graph3.xaxis1.title.text = {}
gr_edit .plotregion1.graph3.xaxis1.title.text.Arrpush "MII = environment"

gr_edit .plotregion1.graph4.title.text = {}
gr_edit .plotregion1.graph4.title.text.Arrpush "Education"
gr_edit .plotregion1.graph4.xaxis1.title.text = {}
gr_edit .plotregion1.graph4.xaxis1.title.text.Arrpush "MII = education"

gr_edit .plotregion1.graph5.title.text = {}
gr_edit .plotregion1.graph5.title.text.Arrpush "Language & culture"
gr_edit .plotregion1.graph5.xaxis1.title.text = {}
gr_edit .plotregion1.graph5.xaxis1.title.text.Arrpush "MII = language & culture"

gr_edit .plotregion1.graph6.title.text = {}
gr_edit .plotregion1.graph6.title.text.Arrpush "Wales vs UK"
gr_edit .plotregion1.graph6.xaxis1.title.text = {}
gr_edit .plotregion1.graph6.xaxis1.title.text.Arrpush "MII = Wales vs UK"

* Tidy up
erase "eco.gph" 
erase "hsc.gph"
erase "env.gph" 
erase "edu.gph" 
erase "lcu.gph" 
erase "wls.gph"

	
	
